package com.geekathon.mobzilla.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.geekathon.mobzilla.model.ExperienceAnalysis;
import com.geekathon.mobzilla.util.LoadBalancingStatistics;
import com.google.gson.Gson;

/**
 * Servlet implementation class ExperienceFactor
 */
@WebServlet("/ExperienceFactor")
public class ExperienceFactor extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public ExperienceFactor() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		List<ExperienceAnalysis> list = LoadBalancingStatistics
				.getExperienceFactor();

		Gson gson = new Gson();
		String jsonString = gson.toJson(list);
		System.out.println(jsonString);
		response.getWriter().print(jsonString);
	}

}
